﻿using System;
using System.Data.SqlClient;


namespace MLY.Reports.dsReportsMLYTableAdapters
{

}
namespace MLY.Reports.dsReportsMLYTableAdapters
{

    public partial class TableWorkOrdersTableAdapter : global::System.ComponentModel.Component
    {
        public SqlCommand[] SelectCommand
        {
            get
            {
                if (this._commandCollection == null)
                {
                    this.InitCommandCollection();
                }
                return this._commandCollection;
            }
            set
            {
                this._commandCollection = value;
            }
        }
        public int FillByWhere(MLY.Reports.dsReportsMLY.TableWorkOrdersDataTable dataTable, string WhereExpression, string OrderByExpression, bool isClient)
        {
            string tempSelect = this.SelectCommand[0].CommandText;
            try
            {
                this._commandCollection[0].CommandText = "SELECT     TableOrganizations.OrganizationName, TableWorkOrder.CustomerWorkOrderNumber, TableWorkOrder.Quantity, " +
                                                                     "TableWorkOrder.CustomerCatalougeCode, TableWorkOrder.ProductDescription, TableWorkOrder.TextFieldA, TableWorkOrder.TextFieldB,  " +
                                                                     "TableWorkOrder.OrderNumber, TableWorkOrder.TotalSum, TableWorkOrder.ContractorWorkOrderNumber, TableWorkOrder.ContractorLotNumber,  " +
                                                                     "TableWorkOrder.SendDate, TableWorkOrder.RequestedDelivaryDate, TableWorkOrder.PlannedDelivaryDate, TableWorkOrder.ActualDelivaryDate,  " +
                                                                     "TableWorkOrder.CustomerPriority, TableWorkOrder.Remarks, TableWorkOrder.CustomerId, TableWorkOrder.ContractorId,  " +
                                                                     "TableWorkOrder.ContractorCatalogueCode " +
                                                           "FROM         TableWorkOrder LEFT OUTER JOIN " +
                                                                         "TableOrganizations ";
                if (isClient)
                {
                    this._commandCollection[0].CommandText += "ON TableOrganizations.OrganizationId = TableWorkOrder.ContractorId";
                }
                else
                {
                    this._commandCollection[0].CommandText += "ON TableOrganizations.OrganizationId = TableWorkOrder.CustomerId";
                }
                string str = string.Empty;
                if (!string.IsNullOrEmpty(WhereExpression))
                {
                    str += " WHERE " + WhereExpression;
                }

                if (!string.IsNullOrEmpty(OrderByExpression))
                {
                    str += " ORDER BY " + OrderByExpression;
                }

                this._commandCollection[0].CommandText += str;
                return this.Fill(dataTable);
            }
            catch //(Exception ex)
            {
                //throw;
            }
            finally
            {
                this._commandCollection[0].CommandText = tempSelect;
            }
            return 0;
        }
    }


    public partial class logTblTableAdapter : global::System.ComponentModel.Component 
    {
        public SqlCommand[] SelectCommand
        {
            get
            {
                if (this._commandCollection == null)
                {
                    this.InitCommandCollection();
                }
                return this._commandCollection;
            }
            set
            {
                this._commandCollection = value;
            }
        }
        public int FillByWhere(MLY.Reports.dsReportsMLY.logTblDataTable dataTable, string WhereExpression, string OrderByExpression)
        {
            string tempSelect = this.SelectCommand[0].CommandText;
            try
            {
                string str = string.Empty;
                if (!string.IsNullOrEmpty(WhereExpression))
                {
                    str += " WHERE " + WhereExpression;
                }

                if (!string.IsNullOrEmpty(OrderByExpression))
                {
                    str += " ORDER BY " + OrderByExpression;
                }

                this._commandCollection[0].CommandText += str;
                return this.Fill(dataTable);
            }
            catch //(Exception ex)
            {
                throw;
            }
            finally
            {
                this._commandCollection[0].CommandText = tempSelect;
            }
            //return 0;
        }
    }
}namespace MLY.Reports {
    
    
    public partial class dsReportsMLY {
    }
}
